# -*- coding: utf-8 -*-

from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()

from sqlalchemy import Column, DateTime, String, BigInteger, Float
from datetime import datetime

class Tick(Base):
    __tablename__ = 'prices'
    
    id         = Column(BigInteger, primary_key=True)
    symbol     = Column(String)
    value      = Column(Float)    
    insertdate = Column(DateTime)
    inserttime = Column(DateTime)
    
   
    def __init__(self, ibmsg):       
        if ibmsg != None:  
            self.symbol     = ibmsg.tickerId
            self.value      = ibmsg.price
            self.insertdate = datetime.utcnow().date()
            self.inserttime = datetime.utcnow()
    
    def __repr__(self):
        return "<Tick(id='%s', symbol='%s', value='%s')>" % (self.id, self.symbol, self.value)
